<?php
namespace app\index\service;


use app\index\model\LegalModel;

class LegalService extends CommonService
{

    public function get_legal_type(){
        return [
            1 => '主诉案件',
            2 => '应诉案件',
        ];
    }
    public function get_legal_type_name($type){
        $arr = $this->get_legal_type();
        $str = isset($arr[$type]) ? $arr[$type] : '';
        return $str;
    }


    public function get_legal_state(){
        return [
            3 => '准备阶段',
            6 => '立案',
            9 => '一审',
            12 => '二审',
            15 => '执行',
            18 => '结案',
        ];
    }
    public function get_legal_state_name($state){
        $arr = $this->get_legal_state();
        $str = isset($arr[$state]) ? $arr[$state] : '';
        return $str;
    }



    public function create_legal_number($types='ZS'){
        $tou = $types.'AJ';
        $daystr = date("Ymd");
        $number = LegalModel::where('number','like','%'.$tou.$daystr.'%')->order('number DESC')->value('number');
        if(!$number){
            $str = $tou.$daystr.'00001';
        }else{
            $str = $tou.((int)str_replace($tou,'',$number)+1);
        }
        return $str;
    }

    public function get_legal_year(){
        $arr = [];
        for ($i=date("Y"); $i>=date("Y")-9; $i--){
            $arr[] = $i;
        }
        return $arr;
    }

}
